#include <Box2D.h>
#include "common.h"
#include "b2WheelJoint.h"

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetSpringDampingRatio
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetSpringDampingRatio();
}

JNIEXPORT void JNICALL Java_b2WheelJoint_jniSetSpringDampingRatio
  (JNIEnv *env, jclass cls, jint addr, jfloat ratio)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	joint->SetSpringDampingRatio(ratio);
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetSpringFrequencyHz
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetSpringFrequencyHz();
}

JNIEXPORT void JNICALL Java_b2WheelJoint_jniSetSpringFrequencyHz
  (JNIEnv *env, jclass cls, jint addr, jfloat hz)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	joint->SetSpringFrequencyHz(hz);
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetMotorTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat inv_dt)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetMotorTorque(inv_dt);
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetMaxMotorTorque
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetMaxMotorTorque();
}

JNIEXPORT void JNICALL Java_b2WheelJoint_jniSetMaxMotorTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat torque)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	joint->SetMaxMotorTorque(torque);
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetMotorSpeed
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetMotorSpeed();
}

JNIEXPORT void JNICALL Java_b2WheelJoint_jniSetMotorSpeed
  (JNIEnv *env, jclass cls, jint addr, jfloat speed)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->SetMotorSpeed(speed);
}

JNIEXPORT void JNICALL Java_b2WheelJoint_jniEnableMotor
  (JNIEnv *env, jclass cls, jint addr, jboolean flag)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	joint->EnableMotor(flag);
}

JNIEXPORT jboolean JNICALL Java_b2WheelJoint_jniIsMotorEnabled
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->IsMotorEnabled();
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetJointSpeed
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetJointSpeed();
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetJointTranslation
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetJointTranslation();
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetLocalAxisA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAxisA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetLocalAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetLocalAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorB();
	return (jint)vec;
}

JNIEXPORT jfloat JNICALL Java_b2WheelJoint_jniGetReactionTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat inv_dt)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	return joint->GetReactionTorque(inv_dt);
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetReactionForce
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetReactionForce();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2WheelJoint_jniGetAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2WheelJoint* joint = (b2WheelJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorB();
	return (jint)vec;
}

#ifdef __cplusplus
}
#endif
